package 面试;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Duo implements Runnable{
    static final Duo duo=new Duo();
    static final CountDownLatch countdown=new CountDownLatch(10);
    @Override
    public void run() {
        try {
            Thread.sleep(new Random().nextInt(10)*1000);
            System.out.println("检查已完毕"+Thread.currentThread().getName());
        }catch (InterruptedException e){
            e.printStackTrace();
        }finally {
            countdown.countDown();
        }
    }


    public static void main(String[] args) throws InterruptedException {
        ExecutorService executorService= Executors.newFixedThreadPool(10);
        for (int i=0;i<10;i++){
            executorService.execute(duo);
        }

        countdown.await();
        System.out.println("所有已检查完毕");


        executorService.shutdown();
    }
}
